//
//  WSPlayerDetailController.m
//  CharonTVProject
//
//  Created by karong on 2023/8/8.
//

#import "WSPlayerDetailController.h"
#import "WSPlayerDetailViewController.h"
#import "GKDYScrollView.h"
#import "WSPlayerRequest.h"
#import "WSVideoDetail.h"
@interface WSPlayerDetailController ()<UIScrollViewDelegate, JXCategoryViewDelegate, JXCategoryListContainerViewDelegate, WSPlayerDetailViewControllerDelegate>
@property (nonatomic, strong) JXCategoryListContainerView *containerView;
@property (weak, nonatomic) IBOutlet UIView *navView;
@property (weak, nonatomic) IBOutlet UIView *chapterView;
@property (weak, nonatomic) IBOutlet UILabel *tvNameLabel;

@end

@implementation WSPlayerDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initUI];
}

- (void)initUI {
    [self.view insertSubview:self.containerView belowSubview:self.navView];
    self.containerView.frame = CGRectMake(0, 0, WSScreenWidth, WSScreenHeight - 56);
}



- (WSPlayerDetailViewController *)playerVC {
    return (WSPlayerDetailViewController *)self.containerView.validListDict[@(0)];
}

- (IBAction)chapterAction:(id)sender {
    [self.playerVC openChapterMenu];
}

#pragma mark WSPlayerDetailViewControllerDelegate
- (void)loadVideoDetailSuccess:(WSVideoDetail *)object {
    self.tvNameLabel.text = WSSF(@"%@·更新至%ld集", object.title, (long)object.total_chapter);
}
#pragma mark - JXCategoryViewDelegate
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
    
}

#pragma mark - JXCategoryListContainerViewDelegate
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
    return 1;
}

- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
    WSPlayerDetailViewController *playerVC = [[WSPlayerDetailViewController alloc] init];
    playerVC.charonTV_video = self.charonTV_video;
    playerVC.delegate = self;
    return playerVC;
}

- (Class)scrollViewClassInlistContainerView:(JXCategoryListContainerView *)listContainerView {
    return GKDYScrollView.class;
}

#pragma mark - 懒加载

- (JXCategoryListContainerView *)containerView {
    if (!_containerView) {
        _containerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
    }
    return _containerView;
}

@end
